﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EntityFrameworks.Entity.Core;
using IRepository.Core;

namespace Common.Background
{
    #region 上下文扩展
    public partial class backgroundEntities : IUnitOfWork
    {

        #region IUnitOfWork 成员

        public void Save()
        {
            this.SaveChanges();
        }

        public bool IsExplicitSubmit
        {
            get;
            set;
        }

        #endregion
    }
    #endregion

    /// <summary>
    /// 提供统一主键的规范
    /// </summary>
    public interface IEntity
    {
        int PrimaryKey { get; }
    }

    #region 实体扩展
    public partial class WebDepartments : ITree<WebDepartments>, IEntity
    {

        #region ITree<WebDepartments> 成员

        public int ID
        {
            get { return this.DepartmentID; }
        }

        public string Name
        {
            get { return this.DepartmentName; }

        }

        public WebDepartments Father { get; set; }

        public IEnumerable<WebDepartments> Sons
        {
            get;
            set;
        }

        #endregion

        /// <summary>
        /// 部门里的人员数量
        /// </summary>
        public int UserCount { get; set; }

        #region IEntity 成员

        public int PrimaryKey
        {
            get { return this.DepartmentID; }
        }

        #endregion

        #region ITree 成员


        public int Level
        {
            get { return this.DeptLevel ?? 0; }
        }

        #endregion
    }
    public class WebDepartments_Ext : WebDepartments { }

    public partial class WebManageMenus : ITree<WebManageMenus>, IEntity
    {
        #region ITree<WebManageMenus> 成员

        public int ID
        {
            get { return this.MenuID; }
        }

        public string Name
        {
            get { return this.MenuName; }
        }

        public WebManageMenus Father
        {
            get;
            set;
        }

        public IEnumerable<WebManageMenus> Sons
        {
            get;
            set;
        }

        public int Level
        {
            get { return this.MenuLevel; }
        }
        #endregion

        #region IEntity 成员

        public int PrimaryKey
        {
            get
            {
                return this.MenuID;
            }
        }

        #endregion
    }

    public partial class WebManageRoles : IEntity
    {

        #region IEntity 成员

        public int PrimaryKey
        {
            get { return this.ManageRoleID; }
        }

        #endregion
    }
    #endregion
}